package com.kyz.speechsdk.ifly;

import android.text.TextUtils;

import androidx.annotation.Keep;

import org.json.JSONObject;

/**
 * create by ZhongZihao on 2019/6/10
 */
@Keep
public class NLPResult {
    private String TAG = "NLPResult";
    private String mRawtext = "";
    private String mJson = "";
    private String iflyAnswer = "";

    public NLPResult(String json) {
        this.parseResult(json);
    }

    private void parseResult(String json) {
        try {
            if (TextUtils.isEmpty(json)) {
                throw new Exception();
            }

            this.mJson = json;
            JSONObject root = new JSONObject(json);
            this.parseRawtext(root);
        } catch (Exception var3) {
            var3.printStackTrace();
        }

    }

    private void parseRawtext(JSONObject root) {
        try {
            this.mRawtext = root.optString("text");
            if (root != null) {
                JSONObject root1 = root.optJSONObject("answer");
                if (root1 != null) {
                    String text = root1.optString("text");
                    if (TextUtils.isEmpty(text)) {
                        this.iflyAnswer = "";
                    } else {
                        this.iflyAnswer = text;
                    }
                }
            }
        } catch (Exception var4) {
            var4.printStackTrace();
        }

    }

    public String getmRawtext() {
        return this.mRawtext;
    }

    public String getmJson() {
        return this.mJson;
    }

    public String getIflyAnswer() {
        return this.iflyAnswer;
    }
}
